import { onMounted, nextTick, ref, watch } from "vue";

const height = ref(0);

const getHeight = (className: string) => {
  onMounted(() => {
    nextTick(() => {
      const TABLE_WRAPPER = document.querySelector(
        className || ".ant-table-wrapper"
      );
      if (!TABLE_WRAPPER) return;
      height.value = TABLE_WRAPPER.clientHeight - 80;
      console.log(height.value);
	  // console.log(document.body.clientHeight,"document.body.clientHeight");
    });
  });
};

const onWatch = (wth: any, className: string) => {
  watch(
    () => wth,
    () => {
      getHeight(className);
    }
  );
  // watch(()=>document.body.clientHeight,()=>{
	 //  console.log(document.body.clientHeight,"wacth");
  // });
};


export default function (watch: any = "", className = "") {
  getHeight(className);
  if (watch) {
    onWatch(onWatch, className);
  }
  return height;
}
